package com.share.rules.api.factory;

import com.share.common.core.domain.R;
import com.share.common.core.exception.ServiceException;
import com.share.rules.api.RemoteFeeRuleService;
import com.share.rules.api.domain.FeeRuleRequestForm;
import com.share.rules.api.domain.FeeRuleResponseVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @return 13141
 * 2025/10/15
 * 8:46
 */
@Component
public class RemoteFeeRuleFallbackFactory implements FallbackFactory<RemoteFeeRuleService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteFeeRuleFallbackFactory.class);

    @Override
    public RemoteFeeRuleService create(Throwable throwable) {
        log.error("规则服务调用失败:{}", throwable.getMessage());

        throw new ServiceException("调用出现错误");
        // return new RemoteFeeRuleService() {
        //
        //     @Override
        //     public R<List<FeeRule>> getFeeRuleList(List<Long> feeRuleIdList, String source) {
        //         return R.fail("获取费用规则列表失败:" + throwable.getMessage());
        //     }
        //
        //     @Override
        //     public R<FeeRule> getFeeRule(Long id, String source) {
        //         return R.fail("获取费用规则信息失败:" + throwable.getMessage());
        //     }
        // };
    }

    // @Override
    // public R<FeeRuleResponseVo> calculateOrderFee(FeeRuleRequestForm calculateOrderFeeForm) {
    //     return R.fail("费用计算失败:" + throwable.getMessage());
    // }
}
